/////////////////////////////////////////////////////////////////////////////
// Name:        gaugepreferences.cpp
// Purpose:     
// Author:      Stephen Whittle
// Modified by: 
// Created:     11/08/2009 12:25:21
// RCS-ID:      
// Copyright:   
// Licence:     
/////////////////////////////////////////////////////////////////////////////

// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"

#ifdef __BORLANDC__
#pragma hdrstop
#endif

#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif

////@begin includes
////@end includes
#include "globals.h"
#include "gaugepreferences.h"

////@begin XPM images
////@end XPM images


/*
 * GaugePreferences type definition
 */

IMPLEMENT_DYNAMIC_CLASS( GaugePreferences, wxDialog )


/*
 * GaugePreferences event table definition
 */

BEGIN_EVENT_TABLE( GaugePreferences, wxDialog )

////@begin GaugePreferences event table entries
    EVT_BUTTON( ID_BUTTON9, GaugePreferences::OnOkClick )

////@end GaugePreferences event table entries

END_EVENT_TABLE()


/*
 * GaugePreferences constructors
 */

GaugePreferences::GaugePreferences()
{
    Init();
}

GaugePreferences::GaugePreferences( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
    Init();
    Create(parent, id, caption, pos, size, style);
}


/*
 * GaugePreferences creator
 */

bool GaugePreferences::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
////@begin GaugePreferences creation
    SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
    wxDialog::Create( parent, id, caption, pos, size, style );

    CreateControls();
    if (GetSizer())
    {
        GetSizer()->SetSizeHints(this);
    }
    Centre();
////@end GaugePreferences creation
    return true;
}


/*
 * GaugePreferences destructor
 */

GaugePreferences::~GaugePreferences()
{
////@begin GaugePreferences destruction
////@end GaugePreferences destruction
}


/*
 * Member initialisation
 */

void GaugePreferences::Init()
{
////@begin GaugePreferences member initialisation
    m_Gauges = NULL;
    m_GaugeString = NULL;
////@end GaugePreferences member initialisation
}


/*
 * Control creation for GaugePreferences
 */

void GaugePreferences::CreateControls()
{    
////@begin GaugePreferences content construction
    GaugePreferences* itemDialog1 = this;

    wxFlexGridSizer* itemFlexGridSizer2 = new wxFlexGridSizer(0, 1, 0, 0);
    itemDialog1->SetSizer(itemFlexGridSizer2);

    m_Gauges = new wxCheckBox( itemDialog1, ID_CHECKBOX3, _("Enable Gauges"), wxDefaultPosition, wxDefaultSize, 0 );
    m_Gauges->SetValue(true);
    itemFlexGridSizer2->Add(m_Gauges, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5);

    wxFlexGridSizer* itemFlexGridSizer4 = new wxFlexGridSizer(0, 1, 0, 0);
    itemFlexGridSizer2->Add(itemFlexGridSizer4, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);

    wxFlexGridSizer* itemFlexGridSizer5 = new wxFlexGridSizer(0, 2, 0, 0);
    itemFlexGridSizer5->AddGrowableCol(1);
    itemFlexGridSizer4->Add(itemFlexGridSizer5, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);

    wxStaticText* itemStaticText6 = new wxStaticText( itemDialog1, wxID_STATIC, _("Gauge Line"), wxDefaultPosition, wxDefaultSize, 0 );
    itemFlexGridSizer5->Add(itemStaticText6, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);

    m_GaugeString = new wxTextCtrl( itemDialog1, ID_TEXTCTRL9, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
    itemFlexGridSizer5->Add(m_GaugeString, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);

    wxStaticBox* itemStaticBoxSizer8Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Gauges"));
    wxStaticBoxSizer* itemStaticBoxSizer8 = new wxStaticBoxSizer(itemStaticBoxSizer8Static, wxVERTICAL);
    itemFlexGridSizer4->Add(itemStaticBoxSizer8, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);

    wxFlexGridSizer* itemFlexGridSizer9 = new wxFlexGridSizer(0, 2, 0, 0);
    itemStaticBoxSizer8->Add(itemFlexGridSizer9, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);

    wxStaticText* itemStaticText10 = new wxStaticText( itemDialog1, wxID_STATIC, _("Filter Pattern"), wxDefaultPosition, wxDefaultSize, 0 );
    itemFlexGridSizer9->Add(itemStaticText10, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);

    wxTextCtrl* itemTextCtrl11 = new wxTextCtrl( itemDialog1, ID_TEXTCTRL10, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
    itemFlexGridSizer9->Add(itemTextCtrl11, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);

    wxFlexGridSizer* itemFlexGridSizer12 = new wxFlexGridSizer(0, 2, 0, 0);
    itemFlexGridSizer12->AddGrowableCol(0);
    itemFlexGridSizer12->AddGrowableCol(1);
    itemFlexGridSizer2->Add(itemFlexGridSizer12, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);

    wxButton* itemButton13 = new wxButton( itemDialog1, ID_BUTTON9, _("Ok"), wxDefaultPosition, wxDefaultSize, 0 );
    itemFlexGridSizer12->Add(itemButton13, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);

    wxButton* itemButton14 = new wxButton( itemDialog1, ID_BUTTON11, _("Button"), wxDefaultPosition, wxDefaultSize, 0 );
    itemFlexGridSizer12->Add(itemButton14, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);

////@end GaugePreferences content construction

 m_Gauges->SetValue(pConfig->Read(wxT("/UI/ShowGauges")));
 m_GaugeString->SetValue (pConfig->Read(wxT("/UI/GaugeString"), wxEmptyString));
}


/*
 * Should we show tooltips?
 */

bool GaugePreferences::ShowToolTips()
{
    return true;
}

/*
 * Get bitmap resources
 */

wxBitmap GaugePreferences::GetBitmapResource( const wxString& name )
{
    // Bitmap retrieval
////@begin GaugePreferences bitmap retrieval
    wxUnusedVar(name);
    return wxNullBitmap;
////@end GaugePreferences bitmap retrieval
}

/*
 * Get icon resources
 */

wxIcon GaugePreferences::GetIconResource( const wxString& name )
{
    // Icon retrieval
////@begin GaugePreferences icon retrieval
    wxUnusedVar(name);
    return wxNullIcon;
////@end GaugePreferences icon retrieval
}


/*
 * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON9
 */

void GaugePreferences::OnOkClick( wxCommandEvent& event )
{
pConfig->Write(wxT("/UI/ShowGauges"), m_Gauges->IsChecked());
pConfig->Write(wxT("/UI/GaugeString"), m_GaugeString->GetValue()); 
pConfig->Flush();
this->EndModal(wxID_OK);
}

